package io.scnb.lesson001.demo8;

import io.scnb.lesson001.demo5.IocUtils;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class PrimaryTest {

    @Test
    public void normalBean() {
        String beanXml = "classpath:/io/scnb/lesson001/demo8/normalBean.xml";
        ClassPathXmlApplicationContext context = IocUtils.context(beanXml);
        // 从容器中获取Iservice接口对应的bean，但是此时容器中有2个候选者
        NormalBean.IService service = context.getBean(NormalBean.IService.class);
        System.out.println(service);
    }

    @Test
    public void setterBean() {
        String beanXml = "classpath:/io/scnb/lesson001/demo8/setterBean.xml";
        ClassPathXmlApplicationContext context = IocUtils.context(beanXml);
    }

    @Test
    public void primaryBean() {
        String beanXml = "classpath:/io/scnb/lesson001/demo8/primaryBean.xml";
        ClassPathXmlApplicationContext context = IocUtils.context(beanXml);
        PrimaryBean.IService service = context.getBean(PrimaryBean.IService.class);
        System.out.println(service);
        PrimaryBean primaryBean = context.getBean(PrimaryBean.class);
        System.out.println(primaryBean);
    }
}
